fix: make all 18 bin/ scripts CDPATH-safe#837
Open
Ziadstr wants to merge 1 commit intogarrytan:mainfrom
Open
Conversation
…uption When CDPATH is set, cd prints the resolved path to stdout, corrupting $(cd ... && pwd) assignments. This breaks all bin/ scripts by doubling the directory path in variable assignments. Fix: redirect cd stdout to /dev/null in all path resolution patterns. pwd still outputs the correct path to stdout for the command substitution. Fixes garrytan#824
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cdstdout in all 18 affectedbin/scripts to preventCDPATHfrom corrupting path resolution>/dev/nullredirect oncdin$(cd ... && pwd)patternsRoot cause
When
CDPATHis set (common with zsh users, zoxide, or custom navigation),cdprints the resolved path to stdout. This doubles the output of$(cd ... && pwd), corruptingGSTACK_DIR,SCRIPT_DIR, andREPO_ROOTassignments. Most visibly,gstack-update-checksilently exits becauseVERSION_FILEbecomes a two-line string.Fix
All 18 scripts fixed
dev-setup, dev-teardown, gstack-community-dashboard, gstack-extension, gstack-learnings-log, gstack-learnings-search, gstack-platform-detect, gstack-relink, gstack-repo-mode, gstack-review-log, gstack-review-read, gstack-specialist-stats, gstack-telemetry-log, gstack-telemetry-sync, gstack-timeline-log, gstack-timeline-read, gstack-uninstall, gstack-update-check.
Testing
All 18 pass syntax check. Fix verified with
CDPATH='.:/tmp'set.Note: PR #836 fixes 7 of 18 scripts. This PR covers all 18.
Fixes #824